﻿@page
@model NoticeClient.Pages.NodesModel
@{
    ViewData["Title"] = "节点列表";
}


@*<div class="weui-cells weui-cells_form">
    <a href="/privacy" class="weui-cell weui-cell_link">
        <div class="weui-cell__bd">新增任务</div>
    </a>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label for="status" class="weui-label">状态</label></div>
        <div class="weui-cell__bd">
            <select class="weui-select" id="status" onchange="loadData()">
                <option value="0">待发送</option>
                <option value="1">已发送</option>
            </select>
        </div>
    </div>
</div>*@
<div class="notice-list">

</div>

@section Scripts{
    <script type="text/javascript">
        loadData();

        function loadData() {
            ajax({

                url: "/Nodes/QueryAll",
                data: {
                    "FilterType": 1,
                    "FilterRules": [],
                    "FilterGroups": []
                },
                type: "POST",
                success: function (data) {
                    $(".notice-list").html('');
                    var html = '<div class="weui-panel__bd">';
                    $.each(data, function (i, o) {
                        html += '<div class="weui-media-box weui-media-box_text">';
                        html += '<h4 class="weui-media-box__title">' + o.nodeName + '</h4>';
                        html += '<p class="weui-media-box__desc">心跳时间: ' + new Date(o.heartbeat).DateFormat("yyyy-MM-dd hh:mm:ss") + '</p>';
                        html += '<p class="weui-media-box__desc">描述: ' + o.description + ' </p>';
                        html += '<ul class="weui-media-box__info">' +
                            '<li class="weui-media-box__info__meta  pull-right">'; 
                        html += '<a onclick="delnode(\'' + (o._Id) + '\')">删除</a>';
                        html += '</li></ul>';
                        html += "</div>";


                    })
                    html += '</div>';
                    $(".notice-list").html(html);
                }

            })

        }
       
        function delnode(id) {
            $.confirm("您确定要删除吗?", "确认删除?", function () {
                ajax({
                    url: "/Nodes/Delete?id=" + id,
                    type: "POST",
                    success: function (data) {
                        if (data.type == 200) { $.toast(data.message); }
                        loadData()
                    }
                })
            }, function () {
                //取消操作
            });


        }

    </script>
}
